<?php namespace App\Exceptions;

use Exception;

class PaymentException extends Exception
{
    const PayConfigNotFound = 0x01;
    const WxConfigNotFound  = 0x02;
    const OrderNotFound     = 0x03;
    const OrderHasPay       = 0x04;
    const CardMoneyNotEnough= 0x06;
    const IntegralNotEnough = 0x07;
    const PayActionWrong    = 0x08;
    const WinTicketNotEnough= 0x09;
    const coinNotEnough     = 0x10;

    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::PayConfigNotFound:
                $message = trans('支付配置未找到');
                break;
            case self::WxConfigNotFound:
                $message = trans('微信配置未找到');
                break;
            case self::OrderNotFound:
                $message = trans('订单不存在');
                break;
            case self::OrderHasPay:
                $message = trans('订单已支付过了，请勿重复支付！');
                break;
            case self::coinNotEnough:
                $message = trans('账户币数量不足!');
                break;
            case self::PayActionWrong:
                $message = trans('支付失败!');
                break;
            default:
                $message = trans('未知错误');
                break;
        }

        parent::__construct($message, $code, $previous);
    }

}